import service from '@/utils/request.ts'


export interface LoginUserInfo{
    username:string,
    password:string,
    uuid:string,
    code:string
}

export interface LoginApiResponse {
  code: number
  msg: string
  data: any
  token?:string //用于LoginController的login返回
  user:any
  roles:string[]
  permissions:string[]
  isDefaultModifyPwd:boolean
  isPasswordExpired:boolean
}

export const API_LOGIN = {
  // 登录方法
    login:(userInfo:LoginUserInfo):Promise<LoginApiResponse>=>{
        return service.post('/login',userInfo,{headers: {
            isToken: false,
            repeatSubmit: false
          },})
    },
    // 注册方法
    register:(data:any)=>{return service.post('/login',data,{headers: {isToken: false,},})},

    // 获取用户详细信息
    getInfo:():Promise<LoginApiResponse> =>{return service.get('/getInfo')},
    // 退出方法
    logout:()=> {return service.post('/logout')},
    // 获取验证码
    getCodeImg:()=> {return service.get('/captchaImage',{headers: {isToken: false},timeout: 20000})},
}

